package com.example.diethealthsystem.service;

import com.example.diethealthsystem.entity.DietRecord;
import com.example.diethealthsystem.repository.DietRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class DietRecordService {

    private final DietRecordRepository dietRecordRepository;

    @Autowired
    public DietRecordService(DietRecordRepository dietRecordRepository) {
        this.dietRecordRepository = dietRecordRepository;
    }

    public List<DietRecord> findAll() {
        return dietRecordRepository.findAll();
    }

    public Optional<DietRecord> findById(Long id) {
        return dietRecordRepository.findById(id);
    }

    public DietRecord save(DietRecord dietRecord) {
        return dietRecordRepository.save(dietRecord);
    }

    public void deleteById(Long id) {
        dietRecordRepository.deleteById(id);
    }

    public List<DietRecord> findByUserId(Long userId) {
        return dietRecordRepository.findByUserId(userId);
    }
} 